package cn.tedu.buycradserver.controller;

import cn.tedu.buycradserver.pojo.dto.CategoryAddNewDTO;
import cn.tedu.buycradserver.service.ICategoryServer;
import cn.tedu.buycradserver.web.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Api(tags = "类别管理模块")
@RestController
@RequestMapping("category")
public class CategoryController {
    @Autowired
    private ICategoryServer categoryServer;

    public CategoryController() {
      log.debug("category可以运行");
    }
    @PostMapping("/addcategory")
    public JsonResult addNew (@RequestBody CategoryAddNewDTO categoryAddNewDTO){
        log.debug("整在添加类别参数为{}",categoryAddNewDTO);
        categoryServer.addNew(categoryAddNewDTO);
        return JsonResult.ok();
    }

    @PostMapping("/deletebyidcategory")
    public JsonResult deleteById(Long id){
        log.debug("参数id为{}",id);
        categoryServer.deleteById(id);
        return JsonResult.ok();
    }

}
